package com.dailywork.basepro.fileoper;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;

/**
 * @author think
 * @version 2019/10/20
 * @since 通用文件操作
 */
public class ComFileOper {
    public static void main(String[] args) throws IOException {
        String file =
                System.getProperty("user.dir") + File.separator + "dir" + File.separator + "dx.properties";
        propertiesFileParse(file);
    }

    /**
     * xml文件解析——流处理
     */
    public static void propertiesFileParse(String file) throws IOException {
        File file1 = new File(file);
        if (!file1.exists()) {
            return;
        }
        InputStream inputStream = ComFileOper.class.getResourceAsStream(file);
        Properties properties = new Properties();
        properties.load(inputStream);
        System.out.println(properties.getProperty("dx.name"));
        System.out.println(properties.getProperty("dx.age"));
    }

    private static void fileOper2() {
        Path path = Paths.get("");
        if (Files.exists(path)) {

        }
    }
}
